package com.realbrand.net.realbrandpay.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Administrator on 2017/6/26.
 */

public class DataBase extends SQLiteOpenHelper {
    // 数据库版本号
    private static final int DATABASE_VERSION = 6;
    // 数据库名
    private static final String DATABASE_NAME = "ShopCar.db";
    // 数据表名
    public static final String TABLE_NAME = "foodstable";
    private static final String USER_TABLE_CREATE = "CREATE TABLE foodstable" +
            "(msgID INTEGER PRIMARY KEY AUTOINCREMENT,name NVARCHAR(20),stroe NVARCHAR(10),adress NVARCHAR(10)," +
            "price NVARCHAR(2),scan NVARCHAR(20),image NVARCHAR(20),activationtime NVARCHAR(20),productionAddress NVARCHAR(20)," +
            "commodityProfile NVARCHAR(512),applyUser NVARCHAR(20),scanState NVARCHAR(20),scanFrequency NVARCHAR(20),scanTime NVARCHAR(20));";

    public DataBase(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    public DataBase(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(USER_TABLE_CREATE);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
        onCreate(db);
    }
}
